import java.util.StringTokenizer;

class P591 {

   public static void main(String[] args) {
       String line = readLn();
       int counter = 1;
       while (!line.equals("0")) {
           System.out.println("Set #" + counter);
           counter ++;
           process(Integer.parseInt(line));
           line = readLn();
           System.out.println();
       }
   }

   private static void process(int i) {
       String line = readLn();
       StringTokenizer st = new StringTokenizer(line);
       int[] array = new int[i];
       int numberOfBlocks = 0;
       for (int k = 0; k < i; k++) {
           array[k] = Integer.parseInt(st.nextToken());
           numberOfBlocks += array[k];
       }
       int medium = numberOfBlocks / i;
       int numberOfMoves = 0;
       for (int k = 0; k < i; k++) {
           if (array[k] > medium) {
               numberOfMoves += array[k] - medium;
           }
       }
       System.out.println("The minimum number of moves is " + numberOfMoves + ".");
   }

   static String readLn() {
       String newLine = System.getProperty("line.separator");
       StringBuffer buffer = new StringBuffer();
       int car = -1;
       try {
           car = System.in.read();
           while ((car > 0) && (car != newLine.charAt(0))) {
               buffer.append((char)car);
               car = System.in.read();
           }
           if (car == newLine.charAt(0))
           System.in.skip(newLine.length() - 1);
       } catch (java.io.IOException e) { return (null);}
       if ((car < 0) && (buffer.length() == 0)) return (null);
       return (buffer.toString()).trim();
   }

}